#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    cin >> n;
    string a;
    cin >> a;

    long long s = 0, h = 0, y = 0;
    for (int i = 0; i < n; i++)
    {
        char ch = a[i];
        if (a[i] == 's') s++;
        else if (a[i] == 'h') h += s;
        else if (a[i] == 'y') y += h;
    }
    cout << y;
    return 0;
}